package com.k12.user.service.impl;

import com.k12.user.model.entity.SysAreaDistricts;
import com.k12.user.mapper.SysAreaDistrictsDao;
import com.k12.user.service.SysAreaDistrictsService;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

/**
 * 区县代码库(SysAreaDistricts)表服务实现类
 *
 * @author makejava
 * @since 2025-07-28 20:53:10
 */
@Service("sysAreaDistrictsService")
public class SysAreaDistrictsServiceImpl implements SysAreaDistrictsService {
    @Resource
    private SysAreaDistrictsDao sysAreaDistrictsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SysAreaDistricts queryById(Integer id) {
        return this.sysAreaDistrictsDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param sysAreaDistricts 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public List<SysAreaDistricts> queryByPage(SysAreaDistricts sysAreaDistricts) {
        return this.sysAreaDistrictsDao.queryAllByLimit(sysAreaDistricts);
    }

    /**
     * 新增数据
     *
     * @param sysAreaDistricts 实例对象
     * @return 实例对象
     */
    @Override
    public SysAreaDistricts insert(SysAreaDistricts sysAreaDistricts) {
        this.sysAreaDistrictsDao.insert(sysAreaDistricts);
        return sysAreaDistricts;
    }

    /**
     * 修改数据
     *
     * @param sysAreaDistricts 实例对象
     * @return 实例对象
     */
    @Override
    public SysAreaDistricts update(SysAreaDistricts sysAreaDistricts) {
        this.sysAreaDistrictsDao.update(sysAreaDistricts);
        return this.queryById(sysAreaDistricts.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.sysAreaDistrictsDao.deleteById(id) > 0;
    }
}
